import React, {Component} from 'react'

import { Route, Switch } from "react-router-dom";

import Home from "./pages/Home";
import About from "./pages/About";
import Header from "./components/Header";
import MyNavLink from "./components/MyNavLink";
import Test from "./pages/Test";

export default class App extends Component {

    render() {
        return (
            <div>
                <div className="row">
                    <div className="col-xs-offset-2 col-xs-6">
                        <Header />
                    </div>
                </div>
                <div className="row">
                    <div className="col-xs-1 col-xs-offset-1">
                        <div className="list-group">
                            <MyNavLink to="/about">About</MyNavLink>
                            <MyNavLink to="/home">Home</MyNavLink>
                        </div>
                    </div>
                    <div className="col-xs-4">
                        <div className="panel">
                            <div className="panel-body">
                                {/*
                                    Switch 的使用
                                    1. 通常情况下，path和component是一一对应的
                                    2. Switch可以提高路由匹配效率(单一匹配)
                                    3. 不加 Switch，浏览器地址栏输入 /home 则下面这种情况是 Home组件和Test组件都会展示
                                */}
                                <Switch>
                                    <Route path="/about" component={About} />
                                    <Route path="/home" component={Home} />
                                    <Route path="/home" component={Test} />
                                </Switch>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        )
    }
}
